package com.comp.controller;

import com.comp.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class Test1Controller {

    @RequestMapping("/test1")
    public String test1(Model model) {
        model.addAttribute("str","test1");
        return "test1";
    }

    @RequestMapping(value = "/test2")
    public String test2() {
        return "test22";
    }

    @RequestMapping(value = "/test3",method = RequestMethod.GET)
    public String test3(Model model) {
        model.addAttribute("str","test3");
        return "test1";
    }

    @RequestMapping(value = "/test4")
    public String test4(Model model,String username,String pwd) {
        model.addAttribute("username",username);
        System.out.println("姓名：" + username);
        System.out.println("密码：" + pwd);
        // model.addAttribute("username","李四");
        return "test4";
    }

    @RequestMapping(value = "/test4_2",method = RequestMethod.POST)
    public String test4_2(Model model, User user) {
        model.addAttribute("username",user.username);
        System.out.println("姓名：" + user.username);
        System.out.println("密码：" + user.pwd);
        // model.addAttribute("username","李四");
        return "test4";
    }

    @RequestMapping(value = "/test4_1",method = RequestMethod.GET)
    public String test4_1(Model model) {
        return "test4_1";
    }
}

